Redim Preserve
Basic syntax x(n)
Usage
Redim Preserve x(n)
Re-dimension the array x to size n, while preserving the initial values in x. x is an array and n is a positive whole number specifying the new size of x.
Examples
The following example is applicable to Basic syntax:
Dim x() As String
'Initialize first three array elements
x = Array ("a", "bb", "ccc")
'Re-size x to 4; old values are retained
Redim Preserve x(4)
'initialize x(4)
x(4) = "dddd"
'return "dddd"
formula = x(4)
Related topics
Array data types (Basic syntax)
Using array variables (Basic syntax)
Crystal syntax x[n]
- Use Redim Preserve x[n] (with the square brackets) only in Crystal syntax, and Redim Preserve x(n) (with the round brackets) only in Basic syntax.
- Unlike Redim Preserve x(n) in Basic syntax, you may not have multiple arrays in one Redim Preserve statement in Crystal syntax.
Usage
Redim Preserve x[n]
Re-dimension the array x to size n, while preserving the initial values in x. x is an array and n is a positive whole number specifying the new size of n.
Examples
The following example is applicable to Crystal syntax:
Local StringVar array x := ["a", "bb", "ccc"];
// resize the array to size 4 while preserving the old values.
Redim Preserve x [4];
// now x = ["a", "bb", "ccc", "dddd"]
x [4] := "dddd";
x[4] // returns "dddd"
Related topics
Array data types (Crystal syntax)
Using array variables (Crystal syntax)